<%--
  Created by IntelliJ IDEA.
  User: luo
  Date: 2020/7/7
  Time: 19:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>案件状态</title>
    <base href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="static/lib/layui-v2.5.5/css/layui.css"  media="all">

</head>
<body>
<fieldset class="layui-elem-field" style="padding: 30px;">
    <legend>案件信息</legend>
    <table lay-filter="case" class="layui-hide" id="case"></table>
</fieldset>

<fieldset class="layui-elem-field" style="padding: 30px;">
    <legend>是否结案</legend>
    <form lay-filter="case" class="layui-form" action="">
        <div class="layui-form-item">
            <div class="layui-input-block">
                <input type="checkbox" name="caseState" lay-skin="switch" lay-text="是|否" lay-filter="case">
            </div>
        </div>
        <button type="button" class="layui-btn layui-col-md-offset4" data-type="reload" id="search">确定</button>
        <button type="reset" class="layui-btn a_back layui-col-md-offset4"><i class="layui-icon layui-icon-close" style="font-size: 24px; color:red;"></i>关闭页面</button>
    </form>
</fieldset>


<script src="static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    var line = parent.line;
    layui.use(['form', 'jquery','table'], function(args){
        var $= layui.jquery;
        var form= layui.form;
        var table= layui.table;
        $('.a_back').click(function () {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });

        table.render({
            elem: '#case'
            ,url:'claims/getCase?policyNum='+line.policyNum
            ,width: 1400
            ,cols: [[
                {field:'claimmainid', minWidth:100, title: '赔案号'}
                ,{field:'casereportid', minWidth:100, title: '报案号'}
                ,{field:'warrantyid', minWidth:100, title: '保单号'}
                ,{field:'filingtime', minWidth:100, title: '立案时间'}
                ,{field:'closecasetime', minWidth:100, title: '结案时间'}
                ,{field:'claimstatus', minWidth:100, title: '赔案主状态'}
            ]]
            ,id:'case'
        });

        layui.$('#search').on('click', function(){
            var data = form.val('case');
            if(data.caseState=="on"){
                line.caseState="结案";
            }else{
                line.caseState="未结案";
            }
            layer.open({
                content: '确定要进行'+line.caseState+'操作吗？'
                ,btn: ['确定', '取消']
                ,yes: function(index, layero){
                    var newdata = {
                        caseState: line.caseState,
                        settlementId: line.settlementId,
                    };
                    $.ajax({
                        url:'/claims/upCase',
                        type:'get',
                        data:newdata,
                        dataType:"json",
                        success:function(data){
                            if(data){
                                layer.msg("操作成功！");
                                setTimeout(function () {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    //关闭当前frame
                                    parent.layer.close(index);
                                    //修改成功后刷新父界面
                                    window.parent.location.reload();
                                }, 800);
                            }
                            else{
                                layer.msg("操作失败！")
                            }
                        },
                        error:function(e){
                            layer.msg("操作失败！")
                        },

                    });
                    return false;
                }
                ,btn2: function(index, layero){
                    layer.close(index);
                }

            });
        });
    });
    layui.use(['jquery'], function(args) {
        var $= layui.jquery;
        if(line.caseState=="结案"){
            $("input[type='checkbox']").prop("checked","true");
        }
    });

</script>
</body>
</html>
